export const PassportSystem = {
  LEVELS: [
    { level: 1, xpRequired: 0, perks: ['基础游戏访问'] },
    { level: 2, xpRequired: 100, perks: ['自定义头像'] },
    { level: 3, xpRequired: 300, perks: ['游戏内表情'] },
    { level: 4, xpRequired: 600, perks: ['每日登录奖励+50%'] },
    { level: 5, xpRequired: 1000, perks: ['专属聊天边框'] },
    { level: 6, xpRequired: 1500, perks: ['游戏加速特权'] },
    { level: 7, xpRequired: 2100, perks: ['好友上限+10'] },
    { level: 8, xpRequired: 2800, perks: ['隐藏游戏成就'] },
    { level: 9, xpRequired: 3600, perks: ['月度特权礼包'] },
    { level: 10, xpRequired: 4500, perks: ['所有游戏特权', '金色边框'] }
  ],

  getUserLevel(userXP) {
    for (let i = this.LEVELS.length - 1; i >= 0; i--) {
      if (userXP >= this.LEVELS[i].xpRequired) {
        return this.LEVELS[i].level;
      }
    }
    return 1;
  },

  getNextLevelProgress(userXP) {
    const currentLevel = this.getUserLevel(userXP);
    if (currentLevel >= 10) return { progress: 1, xpNeeded: 0 };

    const currentLevelData = this.LEVELS[currentLevel - 1];
    const nextLevelData = this.LEVELS[currentLevel];

    const xpInLevel = userXP - currentLevelData.xpRequired;
    const xpToNextLevel = nextLevelData.xpRequired - currentLevelData.xpRequired;

    return {
      progress: xpInLevel / xpToNextLevel,
      xpNeeded: xpToNextLevel - xpInLevel
    };
  }
}; 